package com.leo.result;


import com.leo.common.ReturnCodeEnum;

import java.util.List;

/**
 * 分页返回
 *
 * @author liusl
 * @version 1.0
 * @date 2018/12/8 20:38
 */
public class PageResult<T> extends AbstractResultSupport {

    private long count;
    private List<T> data;

    public static PageResult newPageResult(int code, String desc) {
        return newPageResult(code, desc, 0, null);
    }

    public static PageResult newPageResult(int code, String desc, long count) {
        return newPageResult(code, desc, count, null);
    }

    public static <T> PageResult<T> newPageResult(ReturnCodeEnum returnCode, long count, List<T> data) {
        return newPageResult(returnCode.getReturnCode(), returnCode.getReturnDesc(), count, data);
    }

    public static <T> PageResult<T> newPageResult(int code, String desc, long count, List<T> data) {
        PageResult<T> result = new PageResult<T>();
        result.setCode(code);
        result.setDesc(desc);
        result.setCount(count);
        result.setData(data);
        return result;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
